import type { RouteRecordRaw } from "vue-router";
import { createRouter, createWebHistory } from "vue-router";
import webH5 from "./component/webH5";
import marxism from "./component/marxism";
import englishLearning from "./component/englishLearning";
import demandManagement from "./component/demandManagement";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/webH5",
    component: () => import("@/components/Layout/index.vue"),
    children: [
      {
        path: "/webH5",
        name: "WebH5",
        redirect: "/webH5/webpack",
        component: () => import("@/components/Layout/menuLayout.vue"),
        children: [...webH5],
        meta: {
          title: "web前端",
          name: "WebH5",
        },
      },
      {
        path: "/marxism",
        name: "Marxism",
        redirect: "/marxism/capital",
        component: () => import("@/components/Layout/blankLayout.vue"),
        children: [...marxism],
        meta: {
          title: "马克思主义",
          name: "Marxism",
          hide: true,
        },
      },
      {
        path: "/englishLearning",
        name: "EnglishLearning",
        redirect: "/englishLearning/phonetic_transcription",
        component: () => import("@/components/Layout/blankLayout.vue"),
        children: [...englishLearning],
        meta: {
          title: "英语学习",
          name: "EnglishLearning",
          hide: true,
        },
      },
      {
        path: "/demandManagement",
        name: "DemandManagement",
        redirect: "/demandManagement/daily_tasks",
        component: () => import("@/components/Layout/menuLayout.vue"),
        children: [...demandManagement],
        meta: {
          title: "需求管理",
          name: "DemandManagement",
        },
      },
    ],
  },
  {
    path: "/login",
    name: 'Login',
    component: () => import("@/views/login/index.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

// router.beforeEach((to) => {
//   if (to.path !== "/login") {
//     console.log("非登录");
//   }
// });

export default router;
